<?php
namespace App\Components;
/**
 * 接口返回code状态编号
 * @author 郭钊林
 */
class CodeTools {
    public $result = [
        'code'=>[
            '-1' => '缺少参数',
            '100' => '请求成功',
            //STM信息10开头
            '100001' => '型号不存在',
            '100002' => '版本数据不存在',
        ]
    ];
    //api回调信息公共方法
    public function apiRturn($code,$data=''){
        if($code==0){
            $result = [
                "code" => isset($code) ? intval($code) : 0,
                "msg" => '参数错误',
                "data" => isset($data) ? $data : ''
            ];
        }else{
            $result = [
                "code" => isset($code) ? intval($code) : 0,
                "msg" => '请求成功',
                "data" => isset($data) ? $data : ''
            ];
        }

        return response()->json($result);
    }
}
